<?php 

if ($_POST) {
	include_once './03-08-001.php';

	$newuser=$_POST;

	$user = include './user.php';

	foreach ($user as $v) {
		$arr[]=$v['username'];
	}
	if (in_array($newuser['username'], $arr)) {
		/*echo '用户名已存在';*/
		session_start();
		$_SESSION['username']=$newuser['username'];
		success('用户名已存在，请重新输入','./enroll.php',3);
		exit();
	}elseif ($newuser['username']==null) {
		
		/*echo "请输入用户名";*/
		session_start();
		$_SESSION['username']=$newuser['username'];
		success('请输入用户名','./enroll.php',3);
		exit;
	}

	$newuser['password'] = md5($newuser['password']);


	$user[]=$newuser;
	/*array_push($user, $newuser);*/
	
	$str=var_export($user,true);

	$str="<?php return ".$str."?>";

	file_put_contents('./user.php', $str);
	
	session_start();
	$_SESSION['username']=$newuser['username'];
	$_SESSION['nikename']=$newuser['nikename'];
	success('注册成功','./index.php',3);

}else{
	include './Tpl/enroll.html';
}













 ?>